const promise = new Promise((resolve, reject) => {
	resolve('a');
});
promise
    .then((arg) => { console.log(`执行resolve,参数是${arg}`) })
    .catch((arg) => { console.log(`执行reject,参数是${arg}`) })
    .finally(() => { console.log('结束promise') });

    function* createIterator() {
        yield 1;
        yield 2;
        yield 3;
      }
      // generators可以像正常函数一样被调用，不同的是会返回一个 iterator
      let iterator = createIterator();
      console.log(iterator.next().value); // 1
      console.log(iterator.next().value); // 2
      console.log(iterator.next().value); // 3

      function counter(n){
        return new Promise((resolve, reject) => { 
           resolve(n + 1);
        });
    }
    
    function adder(a, b){
        return new Promise((resolve, reject) => { 
           resolve(a + b);
        });
    }
    
    function delay(a){
        return new Promise((resolve, reject) => { 
           setTimeout(() => resolve(a), 1000);
        });
    }
    
      async function callAll(){
        const count = await counter(1);
        const sum = await adder(count, 3);
        console.log(await delay(sum));
     }
     callAll();// 5
     
   
      
    